package com.yy.job.common.service.impl;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yy.job.common.dao.YYJobStepLogDOMapper;
import com.yy.job.common.dao.po.YYJobStepLogDO;
import com.yy.job.common.service.IBaseService;

@Service
public class YYJobStepLogServiceImpl implements IBaseService<YYJobStepLogDO> {
	
	@Autowired
	private YYJobStepLogDOMapper queueJobTaskExecLogDOMapper;
	
	@Override
	public Long saveSelective(YYJobStepLogDO jobDO) {
		Date nowDate = new Date();
		if (jobDO.getId() == null) {
			if (jobDO.getGmtCreated() == null) {
				jobDO.setGmtCreated(nowDate);
			}
			if (jobDO.getGmtModified() == null) {
				jobDO.setGmtModified(nowDate);
			}
			if (StringUtils.isEmpty(jobDO.getIsDeleted())) {
				jobDO.setIsDeleted("N");
			}
			this.queueJobTaskExecLogDOMapper.insert(jobDO);
			return jobDO.getId();
		} else {
			if (jobDO.getGmtModified() == null) {
				jobDO.setGmtModified(nowDate);
			}
			this.queueJobTaskExecLogDOMapper.updateByPrimaryKeySelective(jobDO);
			return jobDO.getId();
		}
	}
	
}
